#include <iostream>

using namespace std;

/*Billy Dempsey Jr.
  Program #4

Program Description:
        This is a program that asks the user to enter his/her name and number of classes
        they are taking. After this information is entered the user will then enter the
        classes they are taking and their name and classes are printed to screen.


Pseudo Code:
        Class name: Student
        Data:
                    name - String storing student name
                    numClasses - Tracks how many courses the student is in
                    classList - Dynamic array of strings used to store the names of the
                                classes the student is enrolled in.
        Constructors:
                    Student - default Constructor
                    Student - constructor that allows manipulation of the name and number of
                              classes
        Functions:
                    user_Input - Allows the user to enter in information about his name and
                                 classes
                    class_Output - prints the information entered to screen
                    reset_All - Sets the number of classes to 0 and sets all the items in the
                                array to null
                    operator = - Overloads the = operator to help with the calculation of the
                                 number of classes
                    destructor - Releases the memory that has been allocated


  */


class Student
{

    string name;
    int numClasses;
    string *classList; //dynamic array pointer

        public:
            Student();//default constructor
            Student(int , string);//constructor holding an int and string
            Student operator = (Student);//operator = overloaded
            void user_Input();
            void class_Output();
            void reset_All();
            ~Student();//destructor used to release memory
};

Student::Student()//default constructor
{
}

Student::Student(int classes, string student)//constructor
{
    numClasses = classes;
    name = student;

}

Student Student::operator = (Student)// operator = overloaded
{
    Student BrandNew;

    BrandNew.numClasses = numClasses = numClasses;

    return(BrandNew);
}

void Student::user_Input()//function used to have student input information
{
    cout<<"Please enter your name"<<endl;//name entered
    cin>>name;

    cout<<"Please enter the number of classes you have"<<endl;//number of classes entered
    cin>>numClasses;

    cout<<"Please enter your classes: "<<endl;

    classList = new string [numClasses];

    for(int i=0; i<numClasses; i++)//for loop that allows student to input classes
    {
            cin>>classList[i];
    }


}

void Student::class_Output()//outputs the information entered to the screen
{

    cout<<"\nStudent name: "<<name<<endl;

    cout<<"\nClasses: "<<endl;

    for(int i=0; i<numClasses; i++)//iterates through the classList and prints them to screen
    {
            cout<<classList[i];
            cout<<"\n";
    }


}

void Student::reset_All()//sets the contents of the array to null
{
    for(int i=0; i<numClasses; i++)
    {
        classList[i] = "Null";
    }
        numClasses = 0;//sets numClasses to 0
}

Student::~Student()//destructor
{
    if(classList)
    {
        delete[] classList;//deletes the array classList
    }
}

int main()
{
    Student obj;//student object
    //function calls
    obj.user_Input();
    obj.class_Output();
    obj.reset_All();


    return 0;
}
